package com.ruoyi.order.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.order.mapper.StatisticUsersMapper;
import com.ruoyi.order.domain.StatisticUsers;
import com.ruoyi.order.service.IStatisticUsersService;

/**
 * VIEWService业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-08
 */
@Service
public class StatisticUsersServiceImpl implements IStatisticUsersService 
{
    @Autowired
    private StatisticUsersMapper statisticUsersMapper;

    /**
     * 查询VIEW
     * 
     * @param userName VIEWID
     * @return VIEW
     */
    @Override
    public StatisticUsers selectStatisticUsersById(String userName)
    {
        return statisticUsersMapper.selectStatisticUsersById(userName);
    }

    /**
     * 查询VIEW列表
     * 
     * @param
     * @return VIEW
     */
    @Override
    public List<StatisticUsers> selectStatisticUsersList(SysUser user)
    {
        List<SysRole> roles = user.getRoles();
        for (SysRole role : roles) {
            if("片区总管".equals(role.getRoleName())||"棚长".equals(role.getRoleName())||"棚员".equals(role.getRoleName())){
                return statisticUsersMapper.selectStatisticUsersList(user.getUserId());
            }
        }
        return statisticUsersMapper.selectStatisticUsersList(null);
    }

    /**
     * 新增VIEW
     * 
     * @param statisticUsers VIEW
     * @return 结果
     */

}
